#include "logger.h"
#include <fstream>
#include <ctime>


namespace Putin
{
	Logger::Logger()
	{
		fout = std::ofstream(Logger::FILENAME, std::ios::app);
	}

	bool Logger::clear()
	{
		fout.clear();
	}

	/*!
	 * @breif
	 * Write brief comment for loggln here.
	 * 
	 * @param text
	 * The text message to logg
	 * 
	 * @param addTimeStamp
	 * weather or not a time-stamp should be added
	 * 
	 * @returns
	 * Returns true on success
	 * 
	 * Logging a line of text to a specified file
	 */
	bool Logger::loggln(std::string text, bool addTimeStamp)
	{
		time_t rawtime;
		time ( &rawtime );
		std::string theTime( ctime (&rawtime)) ;
		text = theTime + ": " + text + "\n";
		fout.write(text.c_str(),text.size());
	}
}